# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=meson-python
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.18.0
pkgrel=1
pkgdesc="Meson PEP 517 Python build backend (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: meson-python'
  'purl: pkg:pypi/meson-python'
)
msys2_repository_url='https://github.com/mesonbuild/meson-python'
url='https://mesonbuild.com/meson-python/'
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-meson"
         "${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-packaging"
         "${MINGW_PACKAGE_PREFIX}-python-pyproject-metadata")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-build"
  "${MINGW_PACKAGE_PREFIX}-python-installer"
)
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname/-/_}-${pkgver}.tar.gz")
sha256sums=('c56a99ec9df669a40662fe46960321af6e4b14106c14db228709c1628e23848d')

build() {
  cd "${_realname/-/_}-${pkgver}"

  python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${_realname/-/_}-${pkgver}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 "${srcdir}/${_realname/-/_}-${pkgver}/LICENSE" \
    "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
